const db = require("../../../db");
const { SYSTEM_ERROR } = require("../../../utils/errorCode");
exports.main = (req, res) => {
    const { orderId } = req.body;
    // 获取订单信息
    const sql = `select * from orders where orderId = ? and isDelete = 0`
    db.query(sql, orderId, async (err, results) => {
        if (err) return res.err(SYSTEM_ERROR);

        const sql = `select order_detail.productId,productName,order_detail.productPrice,num,cover from order_detail,products where orderId = ? and order_detail.productId = products.productId`;

        db.query(sql, orderId, (err, result) => {
            if (err) {
                console.log(err);
                // 如果查询出错，返回 SYSTEM_ERROR 错误码
                return res.err(SYSTEM_ERROR);
            }
            console.log(results);
            results[0].productList = result;
            return res.sd(results[0])
        })
    })

}


